﻿using System.Drawing.Imaging;
using System;

namespace Sex
{
    public partial class Sex : System.Web.UI.Page
    {
        public class ImageFlag
        {
            public ImageFlags Type;
            public string Name;
            public string Text;
            public ImageFlag(ImageFlags Type, string Name, string Text)
            {
                this.Type = Type;
                this.Name = Name;
                this.Text = Text;
            }
        }
        public class ListImage : MyList
        {
            string GetImageFlags(int Flags)
            {
                string s = "";
                for (int i = 0; i < imgF.Length; i++)
                {
                    if ((Flags & (int)(imgF[i])) > 0)
                        s += (s == "" ? "" : "<br/>") + FormatMyKey(imgF[i].ToString()) + "(" + (int)imgF[i] + ")";
                }
                return s;
            }
            string GetFrameDimensionsList(Guid[] FrameDimensionsList)
            {
                string s = "";
                for (int i = 0; i < FrameDimensionsList.Length; i++)
                {
                    s += (s == "" ? "" : "<br/>") + FrameDimensionsList[i] ;
                }
                return s;
            }
            string GetPropertyIdList(int[] PropertyIdList)
            {
                string s = "";
                for (int i = 0; i < PropertyIdList.Length; i++)
                {
                    s += (s == "" ? "" : "<br/>") + PropertyIdList[i];
                }
                return s;
            }
            public ListImage(State MyState, Img img)
                : base(MyState)
            {
                Add("Path", img.Path);
                Add("Flags", GetImageFlags(img.Flags));
                Add("FrameDimensionsList", GetFrameDimensionsList(img.FrameDimensionsList));
                Add("HorizontalResolution", img.dx.ToString());
                Add("PhysicalDimension.Height", img.y.ToString());
                Add("PhysicalDimension.Width", img.x.ToString());
                Add("PixelFormat", img.pf.ToString());
                Add("PropertyIdList", GetPropertyIdList(img.PropertyIdList));
                Add("RawFormat", img.Format.ToString());
                Add("Tag", (img.Tag==null ? "" : img.Tag.ToString()));
                Add("VerticalResolution", img.dy.ToString());
            }
            public ListImage(State MyState)
                : base(MyState, "Image Flags")
            {
                Add("Caching",          new string[] {ImageFlags.Caching.ToString(),          ((int)ImageFlags.Caching).ToString()});          
                Add("ColorSpaceCmyk",   new string[] {ImageFlags.ColorSpaceCmyk.ToString(),   ((int)ImageFlags.ColorSpaceCmyk).ToString()});   
                Add("ColorSpaceRgb",    new string[] {ImageFlags.ColorSpaceRgb.ToString(),    ((int)ImageFlags.ColorSpaceRgb).ToString()});     
                Add("ColorSpaceGray",   new string[] {ImageFlags.ColorSpaceGray.ToString(),   ((int)ImageFlags.ColorSpaceGray).ToString()});    
                Add("ColorSpaceYcbcr",  new string[] {ImageFlags.ColorSpaceYcbcr.ToString(),  ((int)ImageFlags.ColorSpaceYcbcr).ToString()});   
                Add("ColorSpaceYcck",   new string[] {ImageFlags.ColorSpaceYcck.ToString(),   ((int)ImageFlags.ColorSpaceYcck).ToString()});    
                Add("HasAlpha",         new string[] {ImageFlags.HasAlpha.ToString(),         ((int)ImageFlags.HasAlpha).ToString()});          
                Add("HasTranslucent",   new string[] {ImageFlags.HasTranslucent.ToString(),   ((int)ImageFlags.HasTranslucent).ToString()});    
                Add("HasRealDpi",       new string[] {ImageFlags.HasRealDpi.ToString(),       ((int)ImageFlags.HasRealDpi).ToString()});        
                Add("HasRealPixelSize", new string[] {ImageFlags.HasRealPixelSize.ToString(), ((int)ImageFlags.HasRealPixelSize).ToString()});  
                Add("None",             new string[] {ImageFlags.None.ToString(),             ((int)ImageFlags.None).ToString()});              
                Add("PartiallyScalable",new string[] {ImageFlags.PartiallyScalable.ToString(),((int)ImageFlags.PartiallyScalable).ToString()}); 
                Add("ReadOnly",         new string[] {ImageFlags.ReadOnly.ToString(),         ((int)ImageFlags.ReadOnly).ToString()}); 
                Add("Scalable",         new string[] {ImageFlags.Scalable.ToString(),         ((int)ImageFlags.Scalable).ToString()}); 
            }
            ImageFlags[] imgF = new ImageFlags[] 
            {
                ImageFlags.Caching,          
                ImageFlags.ColorSpaceCmyk,   
                ImageFlags.ColorSpaceRgb,    
                ImageFlags.ColorSpaceGray,   
                ImageFlags.ColorSpaceYcbcr,  
                ImageFlags.ColorSpaceYcck,   
                ImageFlags.HasAlpha,         
                ImageFlags.HasTranslucent,   
                ImageFlags.HasRealDpi,       
                ImageFlags.HasRealPixelSize, 
                ImageFlags.None,             
                ImageFlags.PartiallyScalable,
                ImageFlags.ReadOnly,         
                ImageFlags.Scalable
            };
        }
    }
}